package com.xyy.saas.payment.adpater.jdCredit.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

/**
 * 京东金融支付 订单状态
 */
public enum JdCreditOrderStatusEnum {

    CREATED("CREATED", "创建"),
    FINISH("FINISH", "已完成"),
    EXPIRED("EXPIRED", "过期"),
    CANCEL("CANCEL", "取消"),
    FAIL("FAIL", "失败");

    private String code;
    private String desc;

    private static Map<String, JdCreditOrderStatusEnum> code2Enum;

    static {
        code2Enum = Arrays.asList(values()).stream().collect(Collectors.toMap(JdCreditOrderStatusEnum::getCode, UnaryOperator.identity()));
    }

    JdCreditOrderStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static JdCreditOrderStatusEnum getEnum(String code){
        return code2Enum.get(code);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

}
